﻿using System;
using System.Data;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;
using Ue.Qcdz.Domain.feedbacks;

namespace Ue.Qcdz.Repositories.Feedbacks
{
    internal class FeedbackFactory : IEntityFactory<Feedback>
    {
        internal class FieldNames : FieldNamesBase
        {
            public const string Name = "Name";
            public const string Title = "Title";
            public const string Contact = "Contact";
            public const string Comment = "Comment";
            public const string ShopId = "ShopId";
            public const string CurrentIp = "CurrentIp";
        }
        #region Implementation of IEntityFactory<Feedback>

        public Feedback BuildEntity(IDataReader reader)
        {
            return new FeedbackProxy(
                reader.Get<string>(FieldNames.Name),
                reader.Get<string>(FieldNames.Contact),
                reader.Get<string>(FieldNames.Title),
                reader.Get<string>(FieldNames.Comment),
                reader.Get<string>(FieldNames.ShopId),
                reader.Get<string>(FieldNames.CurrentIp),
                reader.Get<Guid>(FieldNames.EntityKey),
                reader.Get<DateTime>(FieldNames.CreateOn));
        }

        #endregion
    }
}
